﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FineUI;
using ZHDJ.Data;
using ZHDJ.WebPage;

namespace ZHDJ.BranchCenter.BLL
{
    public class PageBase : RolePageBase
    {
        #region 属性
        /// <summary>
        /// 当前组织ID
        /// </summary>
        public string BranchID
        {
            get
            {
                var urlBranchid = Request.QueryString["BranchID"] ?? "";
                return string.IsNullOrEmpty(urlBranchid) ? CurrentUser.BranchID : urlBranchid;
            }
        }

        /// <summary>
        /// 是否和个人中心共用
        /// </summary>
        public virtual bool IsCommonPage
        {
            get
            {
                return false;
            }
        }

        /// <summary>
        /// 是否个人中心
        /// </summary>
        public virtual bool IsPersonalCenter
        {
            get
            {
                var temp = Request.QueryString["IsPersonalCenter"] ?? "";
                return temp == "1";
            }
        }
        #endregion

        #region 页面初始化

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //是否当前组织管理员(包括下级)
            if (!PartyOrg.IsBranchAdmin(CurrentUser.LoginID, BranchID,true)&& !IsCommonPage)
            {
                Response.Write(CHECK_POWER_FAIL_PAGE_MESSAGE);
                Response.End();
            }
            // 此用户是否有访问此页面的权限
            if (!CheckPowerView())
            {
                CheckPowerFailWithPage();
                return;
            }

            // 设置主题
            if (PageManager.Instance != null)
            {
                PageManager.Instance.Theme = (Theme)Enum.Parse(typeof(Theme), ConfigHelper.Theme, true);
            }

            UpdateOnlineUser(User.Identity.Name);

            // 设置页面标题
            Page.Title = ConfigHelper.Title;
        }

        #endregion


    }
}
